﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Infrastructure
{
    /// <summary>
    /// 通用仓储接口
    /// </summary>
    /// <typeparam name="T">实体类型</typeparam>
    public interface IRepository<T> where T : class
    {
        /// <summary>
        /// 查询所有方法
        /// </summary>
        /// <returns>返回符号条件的数据</returns>
        IQueryable<T> GetAll();

 

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>添加结果</returns>
        Task<int> Add(T entity);

        /// <summary>
        /// 异步添加
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>添加结果</returns>
        Task<int> AddAsync(T entity);
        
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns>修改结果</returns>
        Task<int> Update(T entity);

        /// <summary>
        /// 异步修改
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>修改结果</returns>
        Task<int> UpdateAsync(T entity);

        /// <summary>
        /// 添加多条
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>添加结果</returns>
        Task<int> AddRange(List<T> entity);
        
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>返回多条结果</returns>
        Task<int> UpdateRange(List<T> entity);
        
        /// <summary>
        /// 删除实体
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>删除结果</returns>
        Task<int> DeleteAsync(T entity);
    }
}
